<?php 
	require '../../include/library.inc.php';
	
	header("Content-Type: text/xml;charset=UTF-8");
	
	//this is the normal header applied to any Google sitemap.xml file
	$xml =  '<?xml version="1.0" encoding="UTF-8"?>
	<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';
	
	# Main Pages
	
	$xml .= 
		'
			<url>
			<loc>'.HTML_BASE.'</loc>
			<changefreq>weekly</changefreq>
			<priority>1.0</priority>
			</url>
		';
	
	# Blog
	$sql = "SELECT
				text_id,
				seo_url
			FROM
				texts
			ORDER BY
				order_number DESC
			  ";
	$result = query($sql);
	
	while ($row = mysql_fetch_object($result)) {
		
		$url = HTML_BASE.'bg/'.$row->seo_url ;
							
		$xml .= 
		'
			<url>
			<loc>'.$url.'</loc>
			<lastmod>2005-01-01</lastmod>
			<priority>0.8</priority>
			</url>
		';
		
	}
	
	$xml .=
	'</urlset>';


	file_put_contents('../sitemap.xml', $xml);
	
	echo $xml;
?>


